package cn.dengta.webapp.user.entity.activity;

import java.math.BigDecimal;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.Cmp;

/**
 * 世界杯用户下注日志
 *
 * @author Ready
 * @since 2022-11-17
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("act_football_bet_log")
public class ActFootballBetLog extends TimeBasedEntity {

	private static final long serialVersionUID = 1L;

	/** 用户id */
	Long userId;
	/** 场次id */
	Long siteId;
	/** 主场编码 */
	Long masterCode;
	/** 客场编码 */
	Long guestCode;
	/** 下注金币数 */
	Integer golds;
	/** 倍率 */
	BigDecimal ratio;
	/** 押注类型： 1=主场赢；2=客场赢；3=平局 */
	Integer betType;
	/** 赢得金币数 */
	Integer winGolds;
	/** -1=未压中；0=已下注；1=压中；2=已发奖励 */
	Integer status;

	public static ActFootballBetLog of(Long userId, Long siteId, Integer coins, BigDecimal ratio) {
		ActFootballBetLog log = new ActFootballBetLog();
		log.setUserId(userId);
		log.setSiteId(siteId);
		log.setGolds(coins);
		log.setRatio(ratio);
		log.setWinGolds(ratio.multiply(BigDecimal.valueOf(coins)).intValue());
		log.setStatus(0);
		return log;
	}

	public boolean hasWin() {
		return Cmp.eq(this.status, 1);
	}

	public static final String USER_ID = "user_id";
	public static final String SITE_ID = "site_id";
	public static final String GOLDS = "golds";
	public static final String RATIO = "ratio";
	public static final String WIN_GOLDS = "win_golds";
	public static final String STATUS = "status";

}
